import component from 'element-plus/es/components/tree-select/src/tree-select-option.mjs'
import { createRouter, createWebHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
const routes: RouteRecordRaw[] = [
  {
    path: "/login",
    component: () => import("@/views/Login.vue")
  },
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/main',
    name:"main",
    component: () => import("@/views/Main.vue"),
  }
]
// const routesArr=[
//   {
//     path:"password",
//     component:()=>import("@/views/Password.vue")
//   },
//   {
//     path:"customer",
//     component:()=>import("@/views/Customer.vue")
//   },
//   {
//     path:"role",
//     component:()=>import("@/views/Role.vue")
//   },
//   {
//     path:"manager",
//     component:()=>import("@/views/Manager.vue")
//   },
//   {
//     path:"contract",
//     component:()=>import("@/views/Contract.vue")
//   },
//   {
//     path:"menu",
//     component:()=>import("@/views/Menu.vue")
//   },
// ];
const router = createRouter({
  history: createWebHistory(),
  routes
})
router.beforeEach((to, from) => {
  if (to.path !== '/login' && !sessionStorage.getItem("login")) {
    return '/login';
  }
})
export default router
